package com.newly.api.sys.feign;

import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import com.newly.common.base.entity.sys.domain.dto.DomainDto;
import com.newly.common.base.entity.valid.Insert;
import com.newly.common.base.entity.valid.Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: newly-parent
 * @remark: 域
 * @author: guan
 * @create: 2022-01-14 09:18
 */
@Api(tags = "域")
@FeignClient(path = ServerUriConstant.NEWLY_SYS_DOMAIN, name = ServerUriConstant.NEWLY_SYS_SERVICE_NAME)
public interface DomainClient {

    @ApiOperation("创建区域")
    @PostMapping("/create")
    R create(@NotNull(message = "No request parameter") @RequestBody
             @Validated(Insert.class) DomainDto domainDto);

    @ApiOperation("修改区域")
    @PutMapping("/change")
    R change(@NotNull(message = "No request parameter") @RequestBody
             @Validated(Update.class) DomainDto domainDto);

    @ApiOperation("通过id删除区域")
    @DeleteMapping("/deleteByIds")
    R deleteByIds(@NotEmpty(message = "domainIds can't be empty") @RequestParam("domainIds") List<Integer> domainIds);

    @ApiOperation("查询区域列表")
    @GetMapping("/list")
    R listInAuth(@RequestParam(value = "keyword", required = false) String keyword,
                 @RequestParam(value = "fromTime", required = false) String fromTime,
                 @RequestParam(value = "toTime", required = false) String toTime);

    @ApiOperation("通过id查询区域")
    @GetMapping("/queryById")
    R queryById(@NotNull(message = "domainId can't be empty") @RequestParam("domainId") Integer domainId);

    @ApiOperation("查询区域启用状态")
    @GetMapping("/queryEnable")
    R queryEnable();

}
